package com.linewow.xhyy.nihaonew.fragment;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bigkoo.alertview.AlertView;
import com.bigkoo.alertview.OnItemClickListener;
import com.canyinghao.candialog.CanDialog;
import com.canyinghao.candialog.CanDialogInterface;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.linewow.xhyy.hrxb.Constant;
import com.linewow.xhyy.hrxb.DemoHelper;
import com.linewow.xhyy.hrxb.activity.ChatActivity;
import com.linewow.xhyy.nihaonew.R;
import com.linewow.xhyy.nihaonew.activity.BeautyPhotoActivity;
import com.linewow.xhyy.nihaonew.activity.FollowFanActivity;
import com.linewow.xhyy.nihaonew.adapter.NihaoVPAdapter;
import com.linewow.xhyy.nihaonew.application.NiHaoApp;
import com.linewow.xhyy.nihaonew.base.BaseCompatActivity;
import com.linewow.xhyy.nihaonew.base.BaseEntity;
import com.linewow.xhyy.nihaonew.base.BaseFragment;
import com.linewow.xhyy.nihaonew.db.NiHaoHelper;
import com.linewow.xhyy.nihaonew.entity.NiHaoEntity;
import com.linewow.xhyy.nihaonew.entity.NiHaoGeneral;
import com.linewow.xhyy.nihaonew.entity.UserMineInfo;
import com.linewow.xhyy.nihaonew.entity.detail.MineInfo;
import com.linewow.xhyy.nihaonew.entity.image.ImagesInfo;
import com.linewow.xhyy.nihaonew.entity.user.Uinfo;
import com.linewow.xhyy.nihaonew.entity.user.UserInfo;
import com.linewow.xhyy.nihaonew.event.MessageEvent;
import com.linewow.xhyy.nihaonew.model.AppConstants;
import com.linewow.xhyy.nihaonew.model.HttpModel;
import com.linewow.xhyy.nihaonew.net.api.NiHaoOkgo;
import com.linewow.xhyy.nihaonew.util.CommonUtil;
import com.linewow.xhyy.nihaonew.util.Help;
import com.linewow.xhyy.nihaonew.util.NewsCallback;
import com.linewow.xhyy.nihaonew.view.BlurredLayout;
import com.linewow.xhyy.nihaonew.view.VoiceButton2White;
import com.squareup.picasso.Picasso;
import com.zhy.http.okhttp.OkHttpUtils;

import org.simple.eventbus.EventBus;

import java.lang.reflect.Type;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
import rx.functions.Func1;
import rx.schedulers.Schedulers;

/**
 * Created by LXR on 2016/10/10.
 */
public class UserMineMainFragment extends BaseFragment {
    @Bind(R.id.mine_main_bg_img)
    ImageView mineMainBgImg;
    @Bind(R.id.mine_main_blurred)
    BlurredLayout mineMainBlurred;
    @Bind(R.id.widget_mine_configure)
    ImageView widgetMineConfigure;
    @Bind(R.id.widget_mine_back)
    ImageView widgetMineBck;
    @Bind(R.id.widget_mine_avatar)
    ImageView widgetMineAvatar;
    @Bind(R.id.widget_mine_edit_profile)
    RelativeLayout widgetMineEditProfile;
    @Bind(R.id.widget_mine_edit_recorder)
    RelativeLayout widgetMineEditRecorder;
    @Bind(R.id.widget_mine_avatar_rela)
    RelativeLayout widgetMineAvatarRela;
    @Bind(R.id.widget_mine_sign_tv)
    TextView widgetMineSignTv;
    @Bind(R.id.widget_mine_voice_btn)
    VoiceButton2White widgetMineVoiceBtn;
    @Bind(R.id.widget_mine_attention_num)
    TextView widgetMineAttentionNum;
    @Bind(R.id.widget_mine_attention_tv)
    TextView widgetMineAttentionTv;
    @Bind(R.id.widget_mine_fans_num)
    TextView widgetMineFansNum;
    @Bind(R.id.widget_mine_fans_tv)
    TextView widgetMineFansTv;
    @Bind(R.id.widget_mine_like_num)
    TextView widgetMineLikeNum;
    @Bind(R.id.widget_mine_like_tv)
    TextView widgetMineLikeTv;
    @Bind(R.id.mine_main_toolbar)
    Toolbar mineMainToolbar;
    @Bind(R.id.mine_main_tabs)
    TabLayout mineMainTabs;
    @Bind(R.id.mine_main_toolbar_layout)
    CollapsingToolbarLayout mineMainToolbarLayout;
    @Bind(R.id.mine_main_appbar)
    AppBarLayout mineMainAppbar;
    @Bind(R.id.mine_main_viewpager)
    ViewPager mineMainViewpager;
    @Bind(R.id.widget_mine_bottom_line)
    LinearLayout widgetMineBottomLine;
    @Bind(R.id.widget_mine_location_tv)
    TextView widgetMineLocationTv;
    @Bind(R.id.widget_mine_gender_img)
    ImageView widgetMineGenderImg;
    @Bind(R.id.widget_mine_location_relative)
    RelativeLayout widgetMineLocationRelative;
    @Bind(R.id.widget_mine_edit_profile_tv)
    TextView widgetMineEditProfileTv;
    @Bind(R.id.widget_mine_edit_recorder_tv)
    TextView widgetMineEditRecorderTv;
    @Bind(R.id.widget_mine_attention_rela)
    RelativeLayout widgetMineAttentionRela;
    @Bind(R.id.widget_mine_fans_rela)
    RelativeLayout widgetMineFansRela;
    @Bind(R.id.widget_mine_still_nick)
    TextView widgetMineStillNick;
    @Bind(R.id.mine_main_blurred_view)
    View mineMainBlurredView;
    private String TAG = "UserMineMainFragment";
    private Gson gson;
    private Type mineInfoType;
    private NiHaoHelper niHaoHelper;
    private MinePhotoFragment minePhotoFragment;
    private MineTopicFragment mineTopicFragment;
    private Uinfo uinfo;
    private UserInfo userInfo;
    private NihaoVPAdapter nihaoVPAdapter;
    private String[] arrString;

    private View viewPhoto, viewTopic;
    private TextView photoNum, topicNum, photoName, topicName;
    private ImageView photoImg, topicImg;

    @Override
    public View initView() {
        View view = View.inflate(getActivity(), R.layout.fragment_mine_main, null);
        ButterKnife.bind(this, view);
        widgetMineEditRecorderTv.setText(getActivity().getString(R.string.widget_follow_do));
        widgetMineEditProfileTv.setText(getActivity().getString(R.string.widget_send_message));
        RelativeLayout.LayoutParams lr = (RelativeLayout.LayoutParams) widgetMineConfigure.getLayoutParams();
        lr.setMargins(0, CommonUtil.dp2px(getActivity(), 20), 0, 0);
        widgetMineConfigure.setLayoutParams(lr);
        widgetMineConfigure.setImageResource(R.mipmap.icon_menu_white);

        RelativeLayout.LayoutParams lr1 = (RelativeLayout.LayoutParams) widgetMineBck.getLayoutParams();
        lr1.setMargins(0, CommonUtil.dp2px(getActivity(), 20), 0, 0);
        widgetMineBck.setLayoutParams(lr1);
        widgetMineBck.setVisibility(View.VISIBLE);

        return view;
    }

    @Override
    public void initData() {
        super.initData();

        EventBus.getDefault().register(UserMineMainFragment.this);
        niHaoHelper = NiHaoHelper.getInstance();
        initTabLayout();
        if (getArguments() != null) {
            uinfo = getArguments().getParcelable("info");
            initGson();
            requestInfo();
        }
        arrString = new String[]{getString(R.string.menu_report_ad), getString(R.string.menu_report_illegal), getString(R.string.menu_report_sex), getString(R.string.menu_report_deceit), getString(R.string.menu_report_other)};

    }

    /**
     * 初始化  toolbarlayout
     */
    public void initTabLayout() {
        mineMainToolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.color_0));
        mineMainToolbarLayout.setContentScrimColor(getResources().getColor(R.color.colorPrimary));
        mineMainToolbarLayout.setStatusBarScrimColor(getResources().getColor(R.color.colorPrimary));
        mineMainToolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.color_0));
        mineMainToolbarLayout.setCollapsedTitleTextColor(getResources().getColor(R.color.color_0));
        mineMainToolbarLayout.setExpandedTitleGravity(Gravity.CENTER_HORIZONTAL);
        mineMainBlurred.setBlurRadius(0, 50);
        setupViewPager(mineMainViewpager);
        mineMainTabs.setupWithViewPager(mineMainViewpager);
        initTitleView();
    }

    private void initTitleView() {
        viewPhoto = View.inflate(UserMineMainFragment.this.getActivity(), R.layout.item_title, null);
        viewTopic = View.inflate(UserMineMainFragment.this.getActivity(), R.layout.item_title, null);
        photoImg = (ImageView) viewPhoto.findViewById(R.id.item_title_img);
        topicImg = (ImageView) viewTopic.findViewById(R.id.item_title_img);
        photoName = (TextView) viewPhoto.findViewById(R.id.item_title_tv);
        photoNum = (TextView) viewPhoto.findViewById(R.id.item_title_num);
        topicName = (TextView) viewTopic.findViewById(R.id.item_title_tv);
        topicNum = (TextView) viewTopic.findViewById(R.id.item_title_num);
        topicImg.setImageResource(R.mipmap.icon_topic);
        topicName.setText("话题");
        TabLayout.Tab tagPhoto = mineMainTabs.getTabAt(0);
        tagPhoto.setCustomView(viewPhoto);
        TabLayout.Tab tabTopic = mineMainTabs.getTabAt(1);
        tabTopic.setCustomView(viewTopic);
    }


    private void initGson() {
        gson = new Gson();
        mineInfoType = new TypeToken<BaseEntity<MineInfo<UserInfo>>>() {
        }.getType();
    }

    private void setupViewPager(ViewPager mineMainViewpager) {
        nihaoVPAdapter = new NihaoVPAdapter(getFragmentManager());
        minePhotoFragment = new MinePhotoFragment();
        minePhotoFragment.setArguments(getArguments());
        mineTopicFragment = new MineTopicFragment();
        mineTopicFragment.setArguments(getArguments());
        nihaoVPAdapter.addFragment(minePhotoFragment, getString(R.string.widget_photo));
        nihaoVPAdapter.addFragment(mineTopicFragment, getString(R.string.widget_topic));
        mineMainViewpager.setAdapter(nihaoVPAdapter);
    }

    @Override
    public void initList() {
        super.initList();
    }


    private void requestInfo() {
        NiHaoOkgo.userPhoto(uinfo.uid, 0)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .map(new Func1<BaseEntity<UserMineInfo<UserInfo, List<ImagesInfo>>>, UserInfo>() {
                    @Override
                    public UserInfo call(BaseEntity<UserMineInfo<UserInfo, List<ImagesInfo>>> userMineInfoBaseEntity) {
                        return userMineInfoBaseEntity.data.userinfo;
                    }
                })
                .subscribe(new Action1<UserInfo>() {
                    @Override
                    public void call(UserInfo userInfo) {
                        UserMineMainFragment.this.userInfo = userInfo;
                        updateViewBy(userInfo);
                    }
                });
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick({R.id.widget_mine_configure,
            R.id.widget_mine_back,
            R.id.widget_mine_avatar,
            R.id.widget_mine_edit_profile,
            R.id.widget_mine_edit_recorder,
            R.id.widget_mine_attention_rela,
            R.id.widget_mine_sign_tv,
            R.id.widget_mine_fans_rela})
    public void onClick(View view) {

        int id = view.getId();
        switch (id) {
            case R.id.widget_mine_configure:
                if (NiHaoApp.flag) {
                    requestShieldInfo();
                } else {

                    AlertView.Builder builder = new AlertView.Builder().setContext(UserMineMainFragment.this.getActivity())
                            .setStyle(AlertView.Style.ActionSheet)
                            .setTitle(getString(R.string.menu_more))
                            .setCancelText(getString(R.string.menu_cancel));
                    builder.setOthers(new String[]{getString(R.string.menu_report)})
                            .setOnItemClickListener(new OnItemClickListener() {
                                @Override
                                public void onItemClick(Object o, int position) {
                                    switch (position) {
                                        case 0:
                                            DemoHelper.getInstance().onConnectionConflict();
                                            break;
                                    }
                                }
                            });
                }
                break;
            case R.id.widget_mine_avatar:
                startBeautyPhotoActivity();
                break;
            case R.id.widget_mine_edit_profile:
                startChatActivity();
                break;
            case R.id.widget_mine_edit_recorder:

                doAttentionInfo();

                break;
            case R.id.widget_mine_attention_rela:
                Intent intent1 = new Intent(getActivity(), FollowFanActivity.class);
                intent1.putExtra("flag", false);
                Bundle attentionBundle = getArguments();
                intent1.putExtras(attentionBundle);
                startActivity(intent1);
                break;
            case R.id.widget_mine_fans_rela:
                Intent intent2 = new Intent(getActivity(), FollowFanActivity.class);
                intent2.putExtra("flag", true);
                Bundle fanBundle = getArguments();
                intent2.putExtras(fanBundle);
                startActivity(intent2);
                break;
            case R.id.widget_mine_sign_tv:

                break;
            case R.id.widget_mine_back:
                UserMineMainFragment.this.getActivity().finish();
                break;
        }

    }

    private void requestShieldInfo() {
        NiHaoOkgo.shieldInfo("isshield", uinfo.uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<NiHaoGeneral<String>>() {
                    @Override
                    public void call(NiHaoGeneral<String> stringNiHaoGeneral) {
                        AlertView.Builder builder = new AlertView.Builder().setContext(UserMineMainFragment.this.getActivity())
                                .setStyle(AlertView.Style.ActionSheet)
                                .setTitle(getString(R.string.menu_more))
                                .setCancelText(getString(R.string.menu_cancel));
                        if (stringNiHaoGeneral.status) {

                            builder.setOthers(new String[]{getString(R.string.menu_report), getString(R.string.menu_shield_cancel)})
                                    .setOnItemClickListener(new OnItemClickListener() {
                                        @Override
                                        public void onItemClick(Object o, int position) {
                                            if (position == 0) {
                                                showReportView();
                                            } else if (position == 1) {
                                                shieldInfo2();
                                            }
                                        }
                                    })
                                    .build()
                                    .show();

                        } else {
                            builder.setOthers(new String[]{getString(R.string.menu_report), getString(R.string.menu_shield)})
                                    .setOnItemClickListener(new OnItemClickListener() {
                                        @Override
                                        public void onItemClick(Object o, int position) {
                                            if (position == 0) {
                                                Log.e(TAG, "举报了");
                                                showReportView();
                                            } else if (position == 1) {
                                                shieldInfo1();
                                            }
                                        }
                                    })
                                    .build()
                                    .show();

                        }
                    }
                });
    }

    private void showReportView() {

        new CanDialog.Builder(UserMineMainFragment.this.getActivity())
                .setTitle(getString(R.string.menu_report))
                .setSingleChoiceItems(arrString, 1, new CanDialogInterface.OnClickListener() {
                    @Override
                    public void onClick(CanDialog dialog, int position, CharSequence text, boolean[] checkitems) {


                    }
                })
                .setNegativeButton(getString(R.string.widget_cancel), true, null)
                .setPositiveButton(getString(R.string.widget_sure), true, new CanDialogInterface.OnClickListener() {
                    @Override
                    public void onClick(CanDialog dialog, int checkItem, CharSequence text, boolean[] checkItems) {

                        requestReportInfo(checkItem);
                    }
                })
                .setTileAnimator()
                .setCancelable(true)
                .setCircularRevealAnimator(CanDialog.CircularRevealStatus.TOP_LEFT)
                .show();

    }

    private void requestReportInfo(int text) {
        NiHaoOkgo.reportInfo(uinfo.uid, arrString[text])
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<NiHaoGeneral<String>>() {
                    @Override
                    public void call(NiHaoGeneral<String> stringNiHaoGeneral) {

                        Log.e(TAG, "举报成功了" + stringNiHaoGeneral);
                        if (stringNiHaoGeneral.status) {
//                            Toast.makeText(UserMineMainFragment.this.getActivity(), "举报成功",
//                                    Toast.LENGTH_SHORT).show();
                            showSnack(getString(R.string.report_success));
                        } else {
                            showSnack(getString(R.string.report_failed));
                        }
                    }
                });

    }

    private void shieldInfo2() {
        NiHaoOkgo.shieldInfo("shieldoff", uinfo.uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<NiHaoGeneral<String>>() {
                    @Override
                    public void call(NiHaoGeneral<String> stringNiHaoGeneral) {
                        if (stringNiHaoGeneral.status) {
                            ((BaseCompatActivity) getActivity()).showToast(getString(R.string.message_shield2_success));
                        }
                    }
                });
    }

    /**
     * 屏蔽用户的时候
     */
    private void shieldInfo1() {
        NiHaoOkgo.shieldInfo("shieldon", uinfo.uid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<NiHaoGeneral<String>>() {
                    @Override
                    public void call(NiHaoGeneral<String> stringNiHaoGeneral) {
                        if (stringNiHaoGeneral.status) {
                            getActivity().finish();
                        }
                    }
                });
    }

    private void doAttentionInfo() {
        if (NiHaoApp.flag) {
            if (userInfo != null && uinfo != null) {
                if (uinfo.uid.equals(NiHaoApp.uid)) {
                    //自己关注自己
                    return;
                } else {
                    requestAttentionInfo();
                }
            }
        } else {
            DemoHelper.getInstance().onConnectionConflict();
        }
    }

    private void requestAttentionInfo() {
        if (userInfo.followinfo.equals("0")) {
            showLoading();
            OkHttpUtils.get()
                    .url(HttpModel.USERFOLLOW)
                    .addParams("touid", uinfo.uid)
                    .addParams("token", NiHaoApp.token)
                    .build()
                    .execute(new NewsCallback<NiHaoEntity>(NiHaoEntity.class) {
                        @Override
                        public void onError(Call call, Exception e, int id) {
                            Log.e(TAG, "网络请求失败" + e.getMessage());
                            dismissLoading();
                        }

                        @Override
                        public void onResponse(NiHaoEntity response, int id) {
                            dismissLoading();
                            Log.e(TAG, "关注结果返回" + response);
                            if (response.status) {
                                String content = getActivity().getResources().getString(R.string.message_attention_content);
                                niHaoHelper.requestAttention(uinfo.uid, content, uinfo.uid);//这里传什么rid
                                requestInfo();
                                EventBus.getDefault().post(new MessageEvent(), "refresh");
                            }
                        }
                    });

        } else {
            showLoading();
            OkHttpUtils.get()
                    .url(HttpModel.USERUFOLLOW)
                    .addParams("touid", uinfo.uid)
                    .addParams("token", NiHaoApp.token)
                    .build()
                    .execute(new NewsCallback<NiHaoEntity>(NiHaoEntity.class) {
                        @Override
                        public void onError(Call call, Exception e, int id) {
                            Log.e(TAG, "网络请求失败" + e.getMessage());
                            dismissLoading();
                        }

                        @Override
                        public void onResponse(NiHaoEntity response, int id) {
                            Log.e(TAG, "取消结果返回" + response);
                            dismissLoading();
                            if (response.status) {
                                requestInfo();
                                EventBus.getDefault().post(new MessageEvent(), "refresh");
                            }
                        }
                    });
        }
    }

    private void startChatActivity() {
        if (uinfo != null) {
            if (NiHaoApp.flag) {
                Intent intent = new Intent(getActivity(), ChatActivity.class);
                intent.putExtra(Constant.EXTRA_CHAT_TYPE, Constant.CHATTYPE_SINGLE);
                intent.putExtra(Constant.EXTRA_USER_ID, uinfo.uid);
                startActivity(intent);
            } else {
                DemoHelper.getInstance().onConnectionConflict();
            }

        }
    }


    private void updateViewBy(UserInfo userInfo) {

//        mineMainToolbarLayout.setTitle(userInfo.nickname);

        widgetMineStillNick.setText(userInfo.nickname);

        if (userInfo.gender.equals("0")) {
            widgetMineGenderImg.setVisibility(View.GONE);
        } else if (userInfo.gender.equals("1")) {
            widgetMineGenderImg.setImageResource(R.mipmap.icon_gender_male);
        } else {
            widgetMineGenderImg.setImageResource(R.mipmap.icon_gender_female);
        }

        widgetMineAttentionNum.setText(userInfo.follow);
        widgetMineFansNum.setText(userInfo.fans);
        widgetMineLikeNum.setText(userInfo.up);
        if (userInfo.country != null) {
            widgetMineLocationTv.setText(userInfo.country);
        } else {
            widgetMineLocationTv.setText(getString(R.string.message_no_area));
        }

        if (!userInfo.sig_txt.equals("null")) {
            widgetMineSignTv.setText(userInfo.sig_txt);
        } else {
            widgetMineSignTv.setText(getString(R.string.message_user_no_sign));
        }

        Picasso.with(UserMineMainFragment.this.getActivity()).load(userInfo.head_img).error(R.mipmap.err_avatar).fit().into(widgetMineAvatar);
        if (!userInfo.head_img.endsWith(AppConstants.NOAVATAR)) {
            Picasso.with(UserMineMainFragment.this.getActivity()).load(userInfo.head_img).error(R.mipmap.delete3).fit().into(mineMainBgImg);
            mineMainBlurredView.setVisibility(View.VISIBLE);
        } else {
            mineMainBgImg.setImageBitmap(null);
            mineMainBlurredView.setVisibility(View.INVISIBLE);
        }


        if (userInfo.audiopath.equals("")) {
            widgetMineVoiceBtn.setVisibility(View.GONE);
        } else {
            widgetMineVoiceBtn.setVisibility(View.VISIBLE);
        }

        if (userInfo.sig_audiotime.equals("0")) {
            widgetMineVoiceBtn.setVisibility(View.GONE);
        } else {
            widgetMineVoiceBtn.setVisibility(View.VISIBLE);

            widgetMineVoiceBtn.setUrlPath(userInfo.sig_audiotime, userInfo.audiopath);
        }

        if (userInfo.followinfo.equals("0")) {
            widgetMineEditRecorderTv.setText(getActivity().getString(R.string.widget_follow_do));
        } else {
            widgetMineEditRecorderTv.setText(getActivity().getString(R.string.widget_follow_done));
        }

//        nihaoVPAdapter.setFirstTitle(getString(R.string.widget_photo)+" "+userInfo.photonum);
//        nihaoVPAdapter.setSecondTitle(getString(R.string.widget_topic)+" "+userInfo.threadnum);
        photoNum.setText(userInfo.photonum);
        topicNum.setText(userInfo.threadnum);
        mineMainToolbarLayout.setTitle(userInfo.nickname);


    }

    public void startBeautyPhotoActivity() {
        Intent intent = new Intent(UserMineMainFragment.this.getActivity(), BeautyPhotoActivity.class);
        intent.putExtra("uri", userInfo.head_img);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

            final Pair<View, String>[] pairs = Help.createSafeTransitionParticipants
                    (UserMineMainFragment.this.getActivity(), false, new Pair<>(widgetMineAvatar, "beauty"));
            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(UserMineMainFragment.this.getActivity(), pairs);
            startActivity(intent, options.toBundle());
        } else {
            startActivity(intent);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(UserMineMainFragment.this);
    }

}
